<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>成绩</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.css">
    <script src="https://cdn.jsdelivr.net/npm/jquery@3.2/dist/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.js"></script>
</head>
<body>

<nav th:replace="admin/_fragments :: menu(2)"  class="ui inverted  segment">
    <div class="ui container">
        <div class="ui inverted secondary menu">
            <h2 class="ui teal header item">CUMT</h2>
            <h3 class="ui teal header item">在线答题系统</h3>
            <a href="#" class="  item ">教师</a>
            <a href="#" class="active item ">学生</a>
            <div class="right menu   ">
                <div class="ui dropdown item">
                    <div class="text">
                        <!--                        <img src="https://unsplash.it/100/100?image=1005" alt="" class="ui avatar image">-->
                        Zhaohaihang
                    </div>
                    <i class="dropdown icon"></i>
                    <div class="menu">
                        <a href="#" class="item">注销</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</nav>

<div class="ui  container">
    <div  class="ui secondary segment form">
        <input type="hidden" name="page">
        <div class="five fields">
            <div class=" required field">
                <div class="ui left labeled input">
                    <label class="ui teal basic label"> 姓名</label>
                    <input type="text" name="stuname" placeholder="XXXXXX" class="input-box">
                </div>
            </div>
            <div class=" required field">
                <div class="ui left labeled input">
                    <label class="ui teal basic label"> 学号</label>
                    <input type="text" name="stunum" placeholder="XXXXXX" class="input-box">
                </div>
            </div>
            <div class=" required field">
                <div class="ui left labeled action  input">
                    <div class="ui compact  teal basic label">年级</div>
                    <div class="ui fluid selection   dropdown ">
                        <input type="hidden" value="grade" name="stugrade" th:value="*{grade}" class="">
                        <i class="dropdown icon"></i>
                        <div class=" default text ">年级</div>
                        <div class="menu">
                            <div  th:each="gradee : ${grades}"  class="item"  data-value="1" th:data-value="${gradee}" th:text="${gradee}">2019级</div>
                        </div>
                    </div>
                </div>
            </div>
            <div class=" required field">
                <div class="ui left labeled action  input">
                    <div class="ui   compact  teal basic label">老师</div>
                    <div class="ui fluid selection   dropdown ">
                        <input type="hidden" name="teacherid"  >
                        <i class="dropdown icon"></i>
                        <div class=" default text ">老师</div>
                        <div class="menu">
                            <div  th:each="teacher : ${teachers}"  class="item"  data-value="1" th:data-value="${teacher.id}" th:text="${teacher.name}">刘老师</div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="required field">
                <button  id ="clear-btn" class="ui  button">清空</button>
                <button type="button" id="search-btn" class="ui  orange basic button">搜索</button>
            </div>

        </div>

        <div class=" two fields">
            <div class="filed">
                <form action="/admin/importstudent" method="post" enctype="multipart/form-data">
                    <div class="ui input">
                        <input type="file" id="file" name="file" class="ui compact input" placeholder="" >
                    </div>
                    <button class="ui large orange button" type="submit" >批量导入</button>
                </form>
            </div>
        </div>

    </div>

    <div id="table-container">
        <table class="ui celled compact teal table" th:fragment="studentList">
            <thead>
            <tr>
                <th>序号</th>
                <th>ID</th>
                <th>姓名</th>
                <th>学号</th>
                <th>年级</th>
                <th>任课教师</th>
                <th>密码</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <tr th:each="student,iterStat : ${page.content}">
                <td th:text="${iterStat.count}">1</td>
                <td th:text="${student.id}">156</td>
                <td th:text="${student.name}">赵海航</td>
                <td th:text="${student.studentNum}">22150427</td>
                <td th:text="${student.grade}">2019级</td>
                <td th:text="${student.teacher.name}">刘老师</td>
                <td th:text="${student.password}">123456</td>
                <td>
                    <a href="#" th:href="@{/admin/adm-student/{id}/input(id=${student.id})}" class="ui mini basic orange button">编辑</a>
                </td>
            </tr>

            </tbody>
            <tfoot>
            <tr>
                <th colspan="10">
                    <div class="ui  mini  pagination menu" th:if="${page.totalPages}>1">
                        <a  onclick="page(this)" th:attr="data-page=${page.number}-1" class=" item" th:unless="${page.first}">上一页</a>
                        <a  onclick="page(this)" th:attr="data-page=${page.number}+1" class=" item" th:unless="${page.last}">下一页</a>
                    </div>
                    <a href="" th:href="@{/admin/adm-student/input}" class="ui orange right floated mini basic button">新增</a>

                </th>
            </tr>
            </tfoot>
    </table>
    </div>
</div>



<script>


    $('.ui.dropdown').dropdown({
        on: 'hover'
    });

    $('#clear-btn')
        .on('click', function() {
            $('.input-box').val('');
            $('.ui.selection.dropdown')
                .dropdown('clear');
        });
    $("#search-btn").click(function () {
        $("[name='page']").val(0);
        loaddata();
    });
    function loaddata() {
        $("#table-container").load(/*[[@{/admin/adm-student/search}]]*/"/admin/adm-student/search",{
            stuname : $("[name='stuname']").val(),
            stugrade : $("[name='stugrade']").val(),
            stunum : $("[name='stunum']").val(),
            teacherid : $("[name='teacherid']").val(),
            page : $("[name='page']").val()
        });
    };
    function page(obj) {
        $("[name='page']").val($(obj).data("page"));
        loaddata();
    };


</script>
</body>
</html>